#高斯求和,5的高斯求和值: 5 + 4 + 3 + 2 + 1
# num = int(input("请输入目标值:"))
# result = 0 #求和的总值
# for value in range(num): #假如num:10
#   # result = result + (value + 1)
#   result += (value + 1)
# print("高斯求和的值为:",result)

#求一个数的阶乘,5! : 5 * 4 * 3 * 2 * 1
# i一般我们称为索引
# while True:
#   num = int(input("请输入目标值:"))
#   result = 1 #阶乘的总值
#   for i in range(num):
#     result *= (i+1)
#     # result = result * (i + 1)
#   print("阶乘值为:",result)

'''
 循环嵌套
'''
# for i in range(4):
#   for j in range(5):
#     print(i,j)
    
# 求下列算式的结果: 1! + 2! + 3! + ..... + n!
# 1! + 2! + 3! + 4! + 5!
# num = int(input("请输入目标值:"))
# sum = 0 #求和的总值
# for i in range(num):
#   result = 1 #阶乘的总值
#   for j in range(i+1):
#     result *= (j+1)#做阶乘
#   sum += result
# print("算式的结果:",sum)




'''
  break关键字: 跳出整个循环
'''
# for i in range(10):
#   if i == 5:
#     break
#   print(i)

'''
  continue: 跳出当次循环
'''
# for i in range(10):
#   if i == 5:
#     continue
#   print(i)


'''
  pass是空语句，是为了保持程序结构的完整性。可以把它理解为，不做任何事情，相当于一个占位符
'''
# for i in range(10):
#   if i == 5:
#     pass
#   print(i)

'''
  else:else语句是在循环完成之后执行
'''
for i in range(10):
  print(i)
else:
  print("循环结束了")